import pymysql

db = pymysql.connect(host='localhost', user='root', password='mysql', database='python')
cursor = db.cursor()
sql = "select * from activation_code"
try:
    cursor.execute(sql)
    result = cursor.fetchall()
    print(result)
except:
    print("Error: unable to fetch data")
finally:
    db.close()
